/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.makrobioklub.action.web;

import cz.makrobioklub.action.controll.ActionFacadeLocal;
import cz.makrobioklub.action.entity.Action;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import org.fyx.linker.web.LinkerLocal;
import org.fyx.web.context.WebContext;
import org.fyx.web.context.WebPage;

/**
 *
 * @author xljan
 */
@ManagedBean
@RequestScoped
public class ActionShow {
    
    private Action action;

    @EJB
    private ActionFacadeLocal actionFacade;
    @EJB
    private LinkerLocal linker;

    public Action getAction() {
        return action;
    }

    public void setAction(Action action) {
        this.action = action;
    }
    
    public void init(int idAction){
        action = actionFacade.find(idAction);
    }
    
    public void show(Action showAction){
        String url = "action/show.xhtml?p1=" + 
                linker.convertForUrl(showAction.getName()) + "&p2=" +
                Integer.toString(showAction.getIdAction());
        WebPage.redirect(linker.getLink(url));
    }
}
